package com.livemeter;

import java.util.ArrayList;

public class Question {
	public String question;
	public float voteAvg;
	public float vote; // local vote
	public int voteCount;
	long time;

	private static ArrayList<Question> allQuestions = new ArrayList<Question>();

	public static ArrayList<Question> getQuestions() {return allQuestions;}
	public static void addQuestion(Question q) {allQuestions.add(q);}
	
	public static void updateQuestions(ArrayList<Question> questions)
	{
		for (Question q : questions)
		{
			Question q2 = Question.findQuestion(q.question);
			if (q2 != null)
			{
				q2.voteAvg = q.voteAvg;
				q2.voteCount = q.voteCount;
			} else {
				Question.addQuestion(q);
			}
		}
		// TODO: Delete the dropped ones
	}
	
	//private static void clearAll() {allQuestions.clear();}
	public static Question findQuestion(String questionStr)
	{
		for (Question q : allQuestions)
		{
			if (q.question.compareToIgnoreCase(questionStr) == 0)
				return q;
		}
		return null;
	}
}
